package com.ruoyi.system.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.system.domain.FkwzQuestionDetailT;
import com.ruoyi.system.mapper.FkwzQuestionDetailTMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.FkwzQuestionTMapper;
import com.ruoyi.system.domain.FkwzQuestionT;
import com.ruoyi.system.service.IFkwzQuestionTService;

/**
 * 目标单位检查项问卷Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-06-12
 */
@Service
public class FkwzQuestionTServiceImpl implements IFkwzQuestionTService 
{
    @Autowired
    private FkwzQuestionTMapper fkwzQuestionTMapper;

    @Autowired
    private FkwzQuestionDetailTMapper questionDetailTMapper;


    /**
     * 查询目标单位检查项问卷
     * 
     * @param questionId 目标单位检查项问卷主键
     * @return 目标单位检查项问卷
     */
    @Override
    public FkwzQuestionT selectFkwzQuestionTByQuestionId(Long questionId)
    {
         FkwzQuestionT questionT = fkwzQuestionTMapper.selectFkwzQuestionTByQuestionId(questionId);
         List<FkwzQuestionDetailT> fkwzQuestionDetailTS = questionDetailTMapper.selectList(new LambdaQueryWrapper<FkwzQuestionDetailT>()
                .eq(FkwzQuestionDetailT::getQuestionId, questionT.getQuestionId()).eq(FkwzQuestionDetailT::getStatus, 0));
        questionT.setQuestionDetailList(fkwzQuestionDetailTS);
        return questionT;
    }

    /**
     * 查询目标单位检查项问卷列表
     * 
     * @param fkwzQuestionT 目标单位检查项问卷
     * @return 目标单位检查项问卷
     */
    @Override
    public List<FkwzQuestionT> selectFkwzQuestionTList(FkwzQuestionT fkwzQuestionT)
    {
        return fkwzQuestionTMapper.selectFkwzQuestionTList(fkwzQuestionT);
    }

    /**
     * 新增目标单位检查项问卷
     * 
     * @param fkwzQuestionT 目标单位检查项问卷
     * @return 结果
     */
    @Override
    public int insertFkwzQuestionT(FkwzQuestionT fkwzQuestionT)
    {
//        fkwzQuestionT.setCreateTime(DateUtils.getNowDate());
        return fkwzQuestionTMapper.insertFkwzQuestionT(fkwzQuestionT);
    }

    /**
     * 修改目标单位检查项问卷
     * 
     * @param fkwzQuestionT 目标单位检查项问卷
     * @return 结果
     */
    @Override
    public int updateFkwzQuestionT(FkwzQuestionT fkwzQuestionT)
    {
//        fkwzQuestionT.setUpdateTime(DateUtils.getNowDate());
        return fkwzQuestionTMapper.updateFkwzQuestionT(fkwzQuestionT);
    }

    /**
     * 批量删除目标单位检查项问卷
     * 
     * @param questionIds 需要删除的目标单位检查项问卷主键
     * @return 结果
     */
    @Override
    public int deleteFkwzQuestionTByQuestionIds(Long[] questionIds)
    {
        return fkwzQuestionTMapper.deleteFkwzQuestionTByQuestionIds(questionIds);
    }

    /**
     * 删除目标单位检查项问卷信息
     * 
     * @param questionId 目标单位检查项问卷主键
     * @return 结果
     */
    @Override
    public int deleteFkwzQuestionTByQuestionId(Long questionId)
    {
        return fkwzQuestionTMapper.deleteFkwzQuestionTByQuestionId(questionId);
    }
}
